package vip.xiaonuo.modular.controller;

import vip.xiaonuo.core.annotion.BusinessLog;
import vip.xiaonuo.core.annotion.Permission;
import vip.xiaonuo.core.enums.LogAnnotionOpTypeEnum;
import vip.xiaonuo.core.pojo.page.PageResult;
import vip.xiaonuo.core.pojo.response.ResponseData;
import vip.xiaonuo.core.pojo.response.SuccessResponseData;
import vip.xiaonuo.modular.entity.Yuanxi;
import vip.xiaonuo.modular.param.YuanxiParam;
import vip.xiaonuo.modular.service.YuanxiService;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.List;

/**
 * 院系管理控制器
 *
 * @author 春非昔日春
 * @date 2023-03-08 16:34:19
 */
@Controller
public class YuanxiController {

    private String PATH_PREFIX = "yuanxi/";

    @Resource
    private YuanxiService yuanxiService;

    /**
     * 院系管理页面
     *
     * @author 春非昔日春
     * @date 2023-03-08 16:34:19
     */
    @Permission
    @GetMapping("/yuanxi/index")
    public String index() {
        return PATH_PREFIX + "index.html";
    }

    /**
     * 院系管理表单页面
     *
     * @author 春非昔日春
     * @date 2023-03-08 16:34:19
     */
    @GetMapping("/yuanxi/form")
    public String form() {
        return PATH_PREFIX + "form.html";
    }

    /**
     * 查询院系管理
     *
     * @author 春非昔日春
     * @date 2023-03-08 16:34:19
     */
    @Permission
    @ResponseBody
    @GetMapping("/yuanxi/page")
    @BusinessLog(title = "院系管理_查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public PageResult<Yuanxi> page(YuanxiParam yuanxiParam) {
        return yuanxiService.page(yuanxiParam);
    }

    /**
     * 添加院系管理
     *
     * @author 春非昔日春
     * @date 2023-03-08 16:34:19
     */
    @Permission
    @ResponseBody
    @PostMapping("/yuanxi/add")
    @BusinessLog(title = "院系管理_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(YuanxiParam.add.class) YuanxiParam yuanxiParam) {
        yuanxiService.add(yuanxiParam);
        return new SuccessResponseData();
    }

    /**
     * 删除院系管理
     *
     * @author 春非昔日春
     * @date 2023-03-08 16:34:19
     */
    @Permission
    @ResponseBody
    @PostMapping("/yuanxi/delete")
    @BusinessLog(title = "院系管理_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(YuanxiParam.delete.class) List<YuanxiParam> yuanxiParamList) {
        yuanxiService.delete(yuanxiParamList);
        return new SuccessResponseData();
    }

    /**
     * 编辑院系管理
     *
     * @author 春非昔日春
     * @date 2023-03-08 16:34:19
     */
    @Permission
    @ResponseBody
    @PostMapping("/yuanxi/edit")
    @BusinessLog(title = "院系管理_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(YuanxiParam.edit.class) YuanxiParam yuanxiParam) {
        yuanxiService.edit(yuanxiParam);
        return new SuccessResponseData();
    }

    /**
     * 查看院系管理
     *
     * @author 春非昔日春
     * @date 2023-03-08 16:34:19
     */
    @Permission
    @ResponseBody
    @GetMapping("/yuanxi/detail")
    @BusinessLog(title = "院系管理_查看", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(YuanxiParam.detail.class) YuanxiParam yuanxiParam) {
        return new SuccessResponseData(yuanxiService.detail(yuanxiParam));
    }

    /**
     * 院系管理列表
     *
     * @author 春非昔日春
     * @date 2023-03-08 16:34:19
     */
    @Permission
    @ResponseBody
    @GetMapping("/yuanxi/list")
    @BusinessLog(title = "院系管理_列表", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(YuanxiParam yuanxiParam) {
        return new SuccessResponseData(yuanxiService.list(yuanxiParam));
    }

}
